<?php

	// +----------------------------------------------------------------------
	// | 用户管理
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\controller\ucenter;

	use app\event\ucenter\User as UserEvent;
	use app\model\ucenter\User as UserModel;

	class Index extends Common
	{
		public function index()
		{
			$event = new UserEvent();
			$info = $event->customer($this->request->param(), $this->user);
			if (0 == $info['code']) {
				$this->assign('customer', $info['data']);
				return $this->fetch();
			} else {
				$this->error($info['message']);
			}
		}

		/**
		 * 最近信息
		 */
		public function recently()
		{
			$customer = UserModel::get($this->request->post('customer_id'));
			if ($customer) {
				$this->assign('customer', $customer);
				$this->assign('recently', $customer->posts()->limit($this->request->post('limit'))->select());
				$data['html'] = $this->fetch();
			}
			$data['code'] = 0;
			return json($data);
		}
	}
